package com.Arich;

public class Sort {

    public static void main(String[] args) {
        int arr[] ={9,8,1,4,2,3,7,6,5};

        //kuaisu(arr,0,arr.length-1);
        //xuanze(arr);
        //maopao(arr);
        //zhijie(arr);

        for(int i = 0;i<arr.length;i++){
            System.out.print(arr[i]+" ");
        }
    }

    public static void kuaisu(int arr[],int low,int high){
        if(low>high){
            return;
        }
        int i = low;
        int j = high;

        int flag = arr[low];

        while (i<j){
            while (arr[j]>=flag&&i<j){
                j--;
            }
            while (arr[i]<=flag&&i<j){
                i++;
            }
            if (i<j){
                int temp = arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
        arr[low]=arr[i];
        arr[i]=flag;

        kuaisu(arr,low,j-1);
        kuaisu(arr,j+1,high);
    }

    public static void zhijie(int arr[]){
        for(int i =0;i<arr.length-1;i++){
            for(int j = i+1;j>0;j--){
                if(arr[j]<arr[j-1]){
                    int temp = arr[j];
                    arr[j]=arr[j-1];
                    arr[j-1]=temp;
                }
            }
        }
    }

    public static void xuanze(int arr[]){
        for(int i = 0;i<arr.length-1;i++) {
            int mix = i;

            for(int j = i+1;j<arr.length;j++){
                if(arr[j]<arr[mix]){
                    mix = j;
                }
            }

            if(mix!=i){
                int temp = arr[i];
                arr[i]=arr[mix];
                arr[mix]=temp;
            }
        }
    }

    public static void maopao(int arr[]){
        for(int i = 0;i<arr.length-1;i++){
            for(int j = arr.length-1;j>0;j--){
                if(arr[j]<arr[j-1]){
                    int temp = arr[j];
                    arr[j]=arr[j-1];
                    arr[j-1]=temp;
                }
            }
        }
    }
}
